<?php

if (!defined('IN_XLP')) {
    exit('Access Denied!');
}

/**
 * Description of advsAction
 *
 * @author xlp
 */
class contactAction extends commonAction {

    private $cacheFilePre = null; //保存缓存信息的文件名前缀

    function __construct() {
        parent::__construct();
        parent::_checkLogin();
    }

    function index() {
        $p = $this->_getid('p', 1);
        $rs = M('ste_reply')->page($p)->order('create_time desc')->findAll();
        $this->assign(array('rs' => $rs, 'p' => $p, 'total' => M('ste_reply')->getTotal()));
        $this->display();
    }

    function detail() {
        $id = $this->_getid('id' , 0);
        if(!isHave($id)) {
            $this->error('参数丢失');
        }
        $map[ 'id' ] = $id;
        $detail = M('ste_reply')->where($map)->find();
        if(!isHave($detail)) {
            $this->error('留言不存在');
        }
        $where['tid'] = $id;
        $images = M('album')->field("url")->where($where)->findAll();
        $this->assign('detail' , $detail);
        $this->assign('images' , $images);
        $this->display();
    }

    function delete() {
        $id = $this->_postid('id' , 0);
        M('ste_reply')->delete(array('id' => $id));
        $this->JsonReturn('ok',null,1);
    }

}
